﻿using System;
using System.IO;

using TomNet.Extensions;


namespace TomNet.Core.Options
{
    /// <summary>
    /// 上传文件策略
    /// </summary>
    public class UploadOptions
    {
        /// <summary>
        /// 上传路径
        /// </summary>
        private string _uploadPath;
        public string UploadPath
        {
            get
            {
                if (_uploadPath.IsNullOrEmpty())
                {
                    _uploadPath = Path.Combine(AppContext.BaseDirectory, "upload").ToPath();
                }

                if (!Path.IsPathRooted(_uploadPath))
                {
                    _uploadPath = Path.Combine(AppContext.BaseDirectory, _uploadPath).ToPath();
                }

                return _uploadPath;
            }

            set => _uploadPath = value;
        }
        /// <summary>
        /// 策略名称
        /// </summary>
        public string PolicyName { get; set; }

        /// <summary>
        /// 请求路径
        /// </summary>
        public string RequestPath { get; set; }

        /// <summary>
        /// 时间格式 --- 用于上传路径
        /// </summary>
        public string DateTimeFormat { get; set; }

        /// <summary>
        /// 标识 --- 与时间格式组成一个新路径
        /// </summary>
        public string Flag { get; set; }
        /// <summary>
        /// 最大限制
        /// </summary>
        public long MaxSize { get; set; }

        /// <summary>
        /// 允许文件类型
        /// </summary>
        public string[] ContentType { get; set; }
    }
}
